package org.example.journal_items.common;

import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
public class BusinessException extends RuntimeException {
  private final int code;
  private final HttpStatus status;

  public BusinessException(String message) {
    super(message);
    this.code = ResultCode.FAILED.getCode();
    this.status = HttpStatus.INTERNAL_SERVER_ERROR;
  }

  public BusinessException(ResultCode resultCode) {
    super(resultCode.getMessage());
    this.code = resultCode.getCode();
    this.status = HttpStatus.valueOf(resultCode.getCode());
  }

  public BusinessException(ResultCode resultCode, String message) {
    super(message);
    this.code = resultCode.getCode();
    this.status = HttpStatus.valueOf(resultCode.getCode());
  }

  public BusinessException(int code, String message) {
    super(message);
    this.code = code;
    this.status = HttpStatus.valueOf(code);
  }

  public BusinessException(int code, String message, HttpStatus status) {
    super(message);
    this.code = code;
    this.status = status;
  }
}